{{#if collectionNotEmpty}}
<table id="disks-table"
       class="table table-bordered table-striped share-table data-table" width="100%"
       summary="List of disks">
  <thead>
    <tr>
      <th scope="col" abbr="Name">Name</th>
      <th scope="col" abbr="Serial">Serial</th>
      <th scope="col" abbr="Capacity">Capacity</th>
      <th scope="col" abbr="Pool">Pool</th>
      <th scope="col" abbr="SpinDown">Power Status</th>
      <th scope="col" abbr="APM">APM</th>
      <th scope="col" abbr="Model">Model</th>
      <th scope="col" abbr="Transport">Transport</th>
      <th scope="col" abbr="Vendor">Vendor</th>
      <th scope="col" abbr="Smart">S.M.A.R.T</th>
    </tr>
  </thead>
  <tbody>
    {{#each diskCollection}}
    <tr>
      <td><a href="#disks/{{this.id}}"><i class="glyphicon glyphicon-hdd"></i>&nbsp;{{this.name}}</a>
        {{#if this.offline}}
            <a href="#" class="delete" data-disk-id="{{this.id}}" title="Disk is unusable because it is detached.
            Click to delete it from the system if it is not to be reattached." rel="tooltip"><i class="glyphicon glyphicon-trash"></i></a>
        {{else if (isRootDevice this.role)}}
              <i class="glyphicon glyphicon-registration-mark" title="Rockstor System Drive." rel="tooltip"></i>
        {{else if (isLuksContainer this.role)}}
            {{#if this.parted}}
                {{#if (isLuksContainerUnlocked this.role)}}
                    <i class="fa fa-unlock" title="Disk contains at least one partition hosting a LUKS Container (unlocked). LUKS in partition is only supported for the Rockstor system drive." rel="tooltip"></i>
                {{else}}
                    <i class="fa fa-lock" title="Disk contains at least one partition hosting a LUKS Container (locked). LUKS in partition is only supported for the Rockstor system drive." rel="tooltip"></i>
                {{/if}}
            {{else}}
                {{#if (isLuksContainerUnlocked this.role)}}
                    <a href="#disks/luks/{{this.id}}" class="luks_drive" data-disk-id="{{this.id}}" title="Full Disk LUKS Container (unlocked)." rel="tooltip">
                    <i class="fa fa-unlock"></i></a>
                {{else}}
                    <a href="#disks/luks/{{this.id}}" class="luks_drive" data-disk-id="{{this.id}}" title="Full Disk LUKS Container (locked)." rel="tooltip">
                    <i class="fa fa-lock"></i></a>
                {{/if}}
            {{/if}}
        {{else if (isMdraidMember this.role)}}
            <a href="#" class="raid_member" data-disk-id="{{this.id}}" title="Mdraid member (UI pending)." rel="tooltip">
              <i class="glyphicon glyphicon-info-sign"></i></a>
        {{else if (isBcache this.role)}}
            <a href="#" class="bcache_backing_drive" data-disk-id="{{this.id}}" title="Bcache Backing Drive (UI pending)." rel="tooltip">
            <i class="glyphicon glyphicon-link"></i></a>
        {{else if (isBcacheCdev this.role)}}
            <a href="#" class="bcache_caching_drive" data-disk-id="{{this.id}}" title="Bcache Caching Drive (UI pending)." rel="tooltip">
            <i class="glyphicon glyphicon-link"></i><i class="glyphicon glyphicon-link"></i></a>
        {{else if this.parted}}
            {{#if (hasUserRole this.role)}}
                <a href="#disks/role/{{this.id}}" class="user_role_part" data-disk-id="{{this.id}}" title="User Assigned Role found on partitioned disk, click to edit." rel="tooltip">
                <i class="glyphicon glyphicon-tags"></i></a>
                {{#if (isNullPoolBtrfs this.btrfs_uuid this.pool_name)}}
                    <a href="#disks/role/{{this.id}}" class="user_role_part" data-disk-id="{{this.id}}" title="Partition is unusable because it has an existing BTRFS filesystem on it.
                    Click to configure or wipe." rel="tooltip"><i class="fa fa-eraser"></i></a>&nbsp;<a href="#" class="btrfs_import" data-disk-id="{{this.id}}" title="Click to import data (pools, shares and snapshots) on this partition automatically (Note: whole disk btrfs is recommended)." rel="tooltip">
                    <i class="glyphicon glyphicon-circle-arrow-down"></i></a>
                {{else if this.pool_name}}
                    <i class="glyphicon glyphicon-map-marker" title="Drive partition (via Redirect Role) is mapped to a Pool" rel="tooltip"></i>
                {{/if}}
            {{else}}
                {{#if (isNullPoolBtrfs this.btrfs_uuid this.pool_name)}}
                    <a href="#disks/role/{{this.id}}" class="user_role_part" data-disk-id="{{this.id}}" title="Disk is unusable as it contains partitions: one of which has an existing BTRFS filesystem on it. A User Assigned redirect role is required prior to import.
                    Click to configure or wipe." rel="tooltip"><i class="glyphicon glyphicon-cog"></i></a>
                {{else}}
                    <a href="#disks/role/{{this.id}}" class="user_role_part" data-disk-id="{{this.id}}" title="Disk is unusable as it contains partitions and no User Assigned Role.
                    Click to configure or wipe." rel="tooltip"><i class="glyphicon glyphicon-cog"></i></a>
                {{/if}}
            {{/if}}
        {{else}} <!-- We are non of the above top level ifs / else ifs at this point -->
            {{#if (isNullPoolBtrfs this.btrfs_uuid this.pool_name)}}
                <a href="#disks/role/{{this.id}}" class="user_role_part" data-disk-id="{{this.id}}" title="Disk is unusable because it has an existing whole disk BTRFS filesystem on it.
                Click to configure or wipe." rel="tooltip"><i class="fa fa-eraser"></i></a>&nbsp;<a href="#" class="btrfs_import" data-disk-id="{{this.id}}" title="Click to import data (pools, shares and snapshots) on this disk automatically. Multi-device support included." rel="tooltip">
                <i class="glyphicon glyphicon-circle-arrow-down"></i></a>
            {{else}}
                {{#if (hasUserRole this.role)}}
                    <a href="#disks/role/{{this.id}}" class="user_role_whole" data-disk-id="{{this.id}}" title="Whole Disk Role found, click to inspect/edit." rel="tooltip">
                    <i class="glyphicon glyphicon-tag"></i></a>
                {{else}}
                    {{#if this.pool_name}}
                        <i class="glyphicon glyphicon-map-marker" title="Whole drive is mapped to a Pool" rel="tooltip"></i>
                    {{else}}
                        {{#if (isOpenLuks this.role)}}
                            <a href="#disks/role/{{this.id}}" class="no_user_role_whole" data-disk-id="{{this.id}}" title="Assign an optional Whole Disk Role (Excluding LUKS container or bcache), click to edit." rel="tooltip">
                            <i class="glyphicon glyphicon-question-sign"></i></a>
                        {{else}}
                            <a href="#disks/role/{{this.id}}" class="no_user_role_whole" data-disk-id="{{this.id}}" title="Assign an optional Whole Disk Role (ie LUKS/bcache etc), click to edit." rel="tooltip">
                            <i class="glyphicon glyphicon-question-sign"></i></a>
                        {{/if}}
                    {{/if}}
                {{/if}}
            {{/if}}
        {{/if}}
          <!-- All of the following are additive role identification flags,
          they are found independently and in addition to other roles.
          Ie the root fs (flagged above) on an open LUKS container. -->
          {{#if (isOpenLuks this.role)}}
          <a href="#disks/luks/{{this.id}}" class="open_luks_drive" data-disk-id="{{this.id}}"
             title="Open LUKS Volume." rel="tooltip">
              <i class="glyphicon glyphicon-eye-open"></i></a>
          {{/if}}
      </td>
      <td>
        {{#checkSerialStatus this.serial this.name}}
        <div class="alert alert-danger"><h4>Warning! Disk unusable as pool member - serial number is not legitimate or unique.</h4>Disk names may change unfavourably upon reboot leading to inadvertent drive reallocation and potential data loss. This error is caused by the source of these disks such as your Hypervisor or SAN.
          Please ensure that disks are provided with unique serial numbers before proceeding further.</div>
        {{else if this.serial}}
        {{this.serial}}
        &nbsp;&nbsp;&nbsp;&nbsp;<a href="#disks/blink/{{this.id}}" title="A tool to physically identify the hard drive with this serial number." rel="tooltip">
          <i class="fa fa-lightbulb-o fa-lg"></i></a>&nbsp;
        {{/checkSerialStatus}}
      </td>
      <td>{{humanReadableSize this.size}}</td>
      <td>
        {{#if pool_name}}
        <a href="#pools/{{this.pool}}">{{this.pool_name}}</a>
        {{/if}}
      </td>
      <td>
        {{#if (powerStateNullorUnknown this.power_state)}}
          <i class="glyphicon glyphicon-pause"></i>{{this.power_state}} <i class="glyphicon glyphicon-hourglass"></i>
        {{else}}
          {{#if (powerStateActiveIdle this.power_state)}}
            <a href="#" class="pause" data-disk-id="{{this.id}}" title="Force drive into Standby mode." rel="tooltip"><i class="glyphicon glyphicon-pause"></i></a>
          {{else}}
            <i class="glyphicon glyphicon-pause"></i>
          {{/if}}
          {{this.power_state}} <a href="#disks/spindown/{{this.id}}" title="Click to configure Spin Down." rel="tooltip"><i class="glyphicon glyphicon-hourglass"></i></a>
        {{/if}}
        {{this.hdparm_setting}}
      </td>
      <td>{{humanReadableAPM this.apm_level}}</td>
      <td>{{this.model}}</td>
      <td>{{this.transport}}</td>
      <td>{{this.vendor}}</td>
      <td>
        {{#if this.smart_options}}
        {{this.smart_options}}&nbsp;
        {{/if}}
        <a href="#disks/smartcustom/{{this.id}}" title="Click to add/edit Custom SMART options. Rescan to Apply." rel="tooltip-top">
          <i class="glyphicon glyphicon-pencil"></i></a>
        {{#unless smart_available}}
        Not Supported
      </td>
      {{else}}
      <input type="checkbox" data-disk-id="{{this.id}}" data-size="mini" {{#if smart_enabled}}checked{{/if}}></input>
      {{/unless}}
      </td>
    </tr>
    {{/each}}
  </tbody>
</table>
{{else}}
<h4>No disks added. Click on Rescan to discover disks</h4>
{{/if}}
